home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / Generic LaserWriter / Generic LaserWriter.c < prev    next >
Encoding:
Text File  |  1996-06-15  |  2.8 KB  |  137 lines  |  [TEXT/MPS ]

  1. /*-----------------------------------------------------------------------------
  2.  
  3.     Generic LaserWriter.c
  4.     
  5.         This part of the driver demonstrates how to force the PostScript
  6.         imaging system to copy its output to a file.
  7.         
  8.      12/18/93 - dmh - Removed IIg-dependencies for b3.
  9.         9/13/93 - dmh - Updated for the b2 seed.
  10.         9/14/93 - dmh - Disabled the PostScript log which was created in
  11.                                         the Extensions folder.
  12.         3/22/94 - dmh - Balanced gxInitialize override with a gxShutDown one.
  13.         6/14/96 - cn  - Updated to support Universal Interfaces 2.1.
  14.         
  15.     © 1991-1996 Apple Computer Inc.
  16.     
  17. -----------------------------------------------------------------------------*/
  18.  
  19. // If non-zero, we create a PostScript log in the Extensions folder.
  20.  
  21. #define CREATELOG    0
  22.  
  23. #include <GXPrinterDrivers.h>
  24. #include <GXExceptions.h>
  25.  
  26. extern long A5Size (void);
  27. extern void A5Init (void *);
  28.  
  29.  
  30. // Globals...
  31.  
  32. short gLogRefNum;
  33.  
  34.  
  35. OSErr DriverPostScriptDoPageSetup(    gxFormat theFormat,
  36.                                                                          long     pageindx,
  37.                                                                         gxPostScriptImageDataHdl imageDataHdl )
  38. {
  39.     OSErr status;
  40.     char    *setupcommand = (char *) "\p%% File For Level-I or Level-II.\n";
  41.     
  42.     require(CREATELOG, Not_Logging);
  43.     status = Send_GXBufferData( & setupcommand[ 1 ], setupcommand[ 0 ], (long) nil );
  44.     nrequire( status, BufferCommandFailed );
  45.     
  46. Not_Logging:
  47.     
  48.     status = Forward_GXPostScriptDoPageSetup( theFormat, pageindx, imageDataHdl );
  49.     ncheck( status );
  50.     
  51. BufferCommandFailed:
  52.     return( status );
  53. }
  54.  
  55.  
  56.  
  57. OSErr DriverOpenConnection(void)
  58.     {
  59.         OSErr            status;
  60.                 
  61.         status = Forward_GXOpenConnection();
  62.         nrequire(status, failed_Forward);
  63.         require(CREATELOG, Not_Logging);
  64.  
  65.         status = Create("\pPostScriptLog.ps", 0, 'MPS ', 'TEXT');
  66.         ncheck(status);
  67.         status = FSOpen("\pPostScriptLog.ps", 0, &gLogRefNum);
  68.         ncheck(status);
  69.                     
  70.         status = noErr;
  71.     
  72. Not_Logging:
  73. failed_Forward:
  74.         return(status);    
  75.     
  76.     }//DriverOpenConnection
  77.  
  78.  
  79. OSErr    DriverCloseConnection(void)
  80.     {
  81.         OSErr            status;
  82.         long            j;
  83.         
  84.         status = Forward_GXCloseConnection();
  85.         nrequire(status, failed_Forward);
  86.         require(CREATELOG, Not_Logging);
  87.  
  88.         GetFPos(gLogRefNum, &j);
  89.         SetEOF(gLogRefNum, j);
  90.         FSClose(gLogRefNum);
  91.  
  92. Not_Logging:
  93. failed_Forward:
  94.         return(status);
  95.     }
  96.  
  97.  
  98.  
  99. OSErr    DriverInitialize(void)
  100.     {
  101.         OSErr            status;
  102.         
  103.         status = NewMessageGlobals(A5Size(), A5Init);
  104.         nrequire(status, failed_a5);
  105.  
  106. failed_a5:        
  107.         return(status);
  108.     
  109.     }
  110.  
  111.  
  112. OSErr    DriverShutDown(void)
  113.     {
  114.         DisposeMessageGlobals();
  115.         return noErr;
  116.     }
  117.  
  118.  
  119. OSErr DriverDumpBuffer(gxPrintingBuffer *buffPtr)
  120.     {
  121.         OSErr                status;
  122.         long                count;
  123.                 
  124.         require(CREATELOG, Not_Logging);
  125.         count = buffPtr->size;
  126.         
  127.         status = FSWrite(gLogRefNum, &count, buffPtr->data);
  128.         nrequire(status, failed_Write);
  129.     
  130. Not_Logging:
  131.         status = Forward_GXDumpBuffer(buffPtr);
  132.         ncheck(status);
  133.     
  134. failed_Write:
  135.         return(status);
  136.     
  137.     }